package com.hnjme.cnec.common.constant;

/**
 * 业务异常代码枚举
 * @author Luo Liang
 */
public enum JmeBizStatus {
    RECORD_NOT_FOUND(4000,"维护的记录不存在"),
    METHOD_PARAMETER_IS_NULL(5000,"方法参数为空"),
    NOT_DELETABLE(4010,"不满足删除条件"),
    NOT_SUPPORT_TIME_FORMAT(4020,"不支持的查询类型"),
    DUPLICATE(6000,"重复"),
    DUPLICATE_CODE(6001,"重复的编码"),
    DUPLICATE_RECORD(6002,"重复的记录"),
    NO_ACCESS(9001,"无权限操作"),
    FAILED(2005,"系统异常"),
    SUCCESS(2000,"");

    private Integer code;
    private String msg;

    JmeBizStatus(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }
    public String getMsg(){
        return this.msg;
    }
    public Integer getCode(){
        return this.code;
    }

    public static String getMessage(Integer code) {
        for (JmeBizStatus c : JmeBizStatus.values()) {
            if (c.getCode().equals(code)) {
                return c.getMsg();
            }
        }
        return null;
    }
}
